package com.whp.yky.yky.controller;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.GetObjectRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whp.yky.yky.entity.Borrow;
import com.whp.yky.yky.entity.DocumentEntity;
import com.whp.yky.yky.entity.Notice;
import com.whp.yky.yky.entity.poentity.Document;
import com.whp.yky.yky.service.impl.BorrowServiceImpl;
import com.whp.yky.yky.service.impl.DocumentEntityServiceImpl;
import com.whp.yky.yky.service.impl.NoticeServiceImpl;
import com.whp.yky.yky.service.serviceimpl.DocumentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.List;


@Controller
public class IndexController {

    @Autowired
    private DocumentServiceImpl documentService;

    @Autowired
    private NoticeServiceImpl noticeService;

    @Autowired
    private DocumentEntityServiceImpl documentEntityService;

    @Autowired
    private BorrowServiceImpl borrowService;

    @RequestMapping("/index")
    public String index(Model model){
        model.addAttribute("name","whp");
        return "yky/index";
    }

    @RequestMapping("/logistic")
    public String logistic(Model model){
        List<Document> documentList = documentService.getDocumentList();
        model.addAttribute("documentList",documentList);
        return "yky/logistic";
    }

    @RequestMapping("/news")
    public String news( Model model){
        List<Notice> documentList = noticeService.getNoticeList();
        model.addAttribute("documentList",documentList);
        return "yky/news";
    }

    @RequestMapping("/newsDetail/{id}")
    public String newsDetail(@PathVariable(value = "id") int id, Model model){
            Notice notice = noticeService.getNoticeDetailInfo(id);
        model.addAttribute("notice",notice);
        return "yky/newsDetail";
    }

    @RequestMapping("/about")
    public String about(Model model){
        model.addAttribute("name","whp");
        return "yky/about";
    }


    @RequestMapping("/contact")
    public String contact(Model model){
        model.addAttribute("name","whp");
        return "yky/contact";
    }

    @RequestMapping("/product")
    public String product(Model model){
        List<DocumentEntity>documentEntityList = documentEntityService.list();
        model.addAttribute("documentEntityList",documentEntityList);
        return "yky/product";
    }

    @RequestMapping("/panner")
    public String panner(Model model){
        model.addAttribute("name","whp");
        return "yky/panner";
    }

    @RequestMapping("/panner1/{id}")
    public String panner1(@PathVariable(value = "id") int id,Model model){
        List<Borrow> borrowList = borrowService.getPersonnalBorrowList(id);
        model.addAttribute("borrowList",borrowList);
        return "yky/panner1";
    }

    @RequestMapping("/login1")
    public String login1(Model model){

        model.addAttribute("name","whp");
        return "yky/lo_gin";
    }

    @RequestMapping("/panner2/{id}")
    public String panner2(@PathVariable(value = "id") int id,Model model){
        List<Borrow> borrowList = borrowService.getPersonnalBorrowList(id);
        model.addAttribute("borrowList",borrowList);
        return "yky/panner2";
    }

    @RequestMapping("/panner3/{id}")
    public String panner3(@PathVariable(value = "id") int id,Model model){
        List<Borrow> borrowList = borrowService.getPersonnalBorrowList(id);
        model.addAttribute("borrowList",borrowList);
        return "yky/panner3";
    }




}